/*global $, CollectReqInfo*/
$(document).ready(function () {
    $('.top-fixed-box').css({
        'width': '992px',
        'margin-left': '500px'
    });
    $('.terminalpage').css('margin-left', '500px');

    var info = {};
    $('.terminal-ul:first > li').each(function () {
        var key = $(this).find('span:first').text().trim().replace('：', ''),
            val = $(this).find('strong').text().trim();
        info[key] = val;
    });

    var JD = $('.tab-inner-cont:first').html();

    var reqInfo = {
        jobboard: '智联招聘',
        entity: $('.inner-left h2:first').text().trim(),
        title: $('.inner-left h1:first').text().trim(),
        headcount: info['招聘人数'].replace('人', ''),
        workSchedule: info['工作性质'],
        category: info['职位类别'],
        location: info['工作地点'].split(/ |-/).shift(),
        JD: JD.replace(/\r\n|\n/g, '')
              .replace(/<\/div>\s*<div[^>]*>/gi, '\n')
              .replace(/<div[^>]*>/gi, '\n')
              .replace(/<\/p>\s*<p[^>]*>/gi, '\n')
              .replace(/<p[^>]*>/gi, '\n')
              .replace(/<\/ol>/gi, '\n\n')
              .replace(/<\/li[^>]*>\s*<li>/gi, '\n0.')
              .replace(/<li[^>]*>/gi, '\n0.')
              .replace(/<br[^>]*>/gi, '\n')
              .replace(/<\/?[^>]+>/gi, '')
              .replace(/&nbsp;/g, '')
    };

    CollectReqInfo.init($('body'), reqInfo);
});